package bigbrother.modules.time;

import bigbrother.command.AbstractCommand;
import bigbrother.modules.AbstractModule;
import org.apache.wicket.Component;
import org.joda.time.DateTime;

/**
 * Provides a command that returns the current time (as currently set on the server the IRC bot is running on). Also
 * serves as a simple example of a module.
 *
 * @author Hans Haggstrom
 */
public final class TimeModule
        extends AbstractModule
{

    //======================================================================
    // Public Methods

    //----------------------------------------------------------------------
    // Constructors

    public TimeModule()
    {
        super( "time" );

        registerCommand( new AbstractCommand( "", "Prints the current time of the server where the IRC bot is hosted." )
        {

            public String doCommand( final String channel,
                                     final String sender,
                                     final String login,
                                     final String hostname,
                                     final String parameters )
            {
                return new DateTime().toString();
            }

        } );
    }

    //----------------------------------------------------------------------
    // Module Implementation


    public synchronized Component createWebComponent( final String id )
    {
        return null;
    }

    //======================================================================
    // Protected Methods

    protected void onModuleStarted()
    {

    }


    protected void onModuleStopped()
    {

    }

}
